import { PaginationProps } from 'element-plus';
import { MakeRequired, UnReadonly } from './util';

export enum HandlerType {
  'page',
  'size',
  'prev',
  'next',
}
/**
 * 默认参数
 */
export interface DefaultPaginationProps {
  pageSize: number;
  currentPage: number;
  total: number;
  pageCount: number;
}

/**
 * 分页事件统一抛出
 */
export interface PaginationHandler {
  (value: number, type: HandlerType): void;
}

/**
 * 所有参数非必填
 */
export type BasicPaginationProps = Partial<
  UnReadonly<PaginationProps> & {
    handler: PaginationHandler;
  }
>;

/**
 * 默认参数必填
 */
export type RequiredDefaultProps = MakeRequired<BasicPaginationProps, keyof DefaultPaginationProps>;

/**
 * 分页请求参数
 */
export interface PaginationMeta {
  page: number;
  size: number;
}

/**
 * 分页变化的回调
 */
export type PaginationFun = () => void;
